package com.yanqu.road.server.cmd.activity.tonbingchannel.channel;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.ChannelTonBingProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.tonbingchannel.ChannelTonBingModule;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.protocol.GameProtocol;
import io.netty.channel.ChannelHandlerContext;


@Cmd(code = GameProtocol.S_CHANNEL_CTON_BING_RED_PACKET_BOX_VALUE_SYNC, desc = "")
public class TonBingRedPacketBoxValueSyncCmd implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        ChannelTonBingProto.ChannelTonBingRedPacketBoxValueSyncMsg syncMsg = ChannelTonBingProto.ChannelTonBingRedPacketBoxValueSyncMsg.parseFrom(packet.getBytes());
        int activityId = syncMsg.getActivityId();
        long playerId = packet.getPlayerId();
        GamePlayer player = GamePlayerMgr.getOnlinePlayer(playerId);
        if (player != null) {
            player.getModule(ChannelTonBingModule.class).notifyRedPackValue(activityId, syncMsg.getValue());
        }
    }

}
